<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>登录</title>
    <!--<link href="../static/css/auth.css" rel="stylesheet" type="text/css">-->
    <!--<link href="../static/css/bg.css" rel="stylesheet" type="text/css"/>-->

    <!-- 地址栏显示 -->
    <link rel="Shortcut Icon" th:href="@{/images/hospital.ico}" type="image/x-icon"/>
    <link th:href="@{/xtiper/css/xtiper.css}" type="text/css" rel="stylesheet"/>
    <script th:src="@{/xtiper/js/xtiper.js}" type="text/javascript"></script>

    <!-- 收藏栏也显示 -->
    <link rel="Bookmark" th:href="@{/images/hospital.ico}" type="image/x-icon"/>
    <link th:href="@{/css/auth.css}" rel="stylesheet" type="text/css">
    <link th:href="@{/css/bg.css}" rel="stylesheet" type="text/css"/>
    <link th:href="@{http://cdn.bootcss.com/font-awesome/4.5.0/css/font-awesome.min.css}" rel="stylesheet"
          type="text/css"/>
    <link th:href="@{/css/mcss/mcss_login.css}" rel="stylesheet">
    <link rel="stylesheet" type="text/css" th:href="@{/css/sweetalert.css}">
</head>


<body onload="getCookie();choseRole()">

<div class="lowin">

    <div class="lowin-brand">
        <img th:src="@{/images/hospitory.png}" alt="logo">
    </div>
    <div class="lowin-wrapper">
        <div class="lowin-box lowin-login">
            <div class="lowin-box-inner">
                <form>
                    <p>Welcome</p>
                    <div class="lowin-group">
                        <label>Email </label>
                        <input type="email" autocomplete="email" name="email" id="email" class="lowin-input">
                    </div>
                    <div class="lowin-group password-group">
                        <label>Password </label>
                        <input type="password" name="plainPassword" id="plainPassword" class="lowin-input">
                    </div>

                    <div class="lowin-group">
                         <a th:href="@{/admin/loginByPhone}">忘记密码</a>

                    </div>

                    <input id="loginId" type="button" style="text-align: center" class="lowin-btn login-btn"
                           value="登&emsp;录" onclick="dologin()">


                    <div class="text-foot">
                        &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                        &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                        &emsp;&emsp;&emsp;&emsp;<a href="" class="register-link">注册</a>
                    </div>
                </form>
            </div>
        </div>

        <div class="lowin-box lowin-register">
            <div class="lowin-box-inner">
                <p>Register</p>
                <div class="lowin-group">

                    <input type="text" name="username" id="username" autocomplete="username" placeholder="Name"
                           class="lowin-input">
                </div>
                <div class="lowin-group">
                    <input type="password" name="plainPassword" autocomplete="current-password"
                           id="registerPassword" placeholder="Password" class="lowin-input">
                </div>
                <div class="lowin-group">
                    <input type="email" autocomplete="email" name="email" id="email1"
                           placeholder="Email"
                           class="lowin-input">
                </div>

                <div class="lowin-group">
                    <input type="tel"  id="code" placeholder="验证码" class="lowin-input">
                </div>
                <div class="lowin-group">
                    <a type="button"  id="sendBtn" href="#" style="padding: 5px">发送验证码</a>
                </div>

                <div class="select dowebok" style="text-align: center">
                   <!-- <select name="dId">
                    <option value="">&#45;&#45;请选择角色&#45;&#45;</option>
                        <li th:each="rolelist:${session.roleList}">&lt;!&ndash;/*@thymesVar id="role" type=""*/&ndash;&gt;
                        &lt;!&ndash;<a th:text="${rolelist.role}"></a></li>&ndash;&gt;
                        <option value=" ${rolelist.role}">${rolelist.role}</option>
                        </li>
                    </select>-->

                    <select name="description" id="description" style="padding: 3px;color:#00a7d0;" >
                        <option >--请选择角色--</option>
                        <option  th:each="rolelist:${session.roleList}" th:value="${rolelist.description}" th:text="${rolelist.description}" style="text-align: center"></option>
                    </select>

                </div>
                <br>
                <button class="lowin-btn" onclick="register()">
                    注&emsp;册
                </button>

                <div class="text-foot">
                    &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                    &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
                    &emsp;&emsp;&emsp;&emsp;<a href="" class="login-link">登录</a>
                </div>
            </div>
        </div>
        <div class="modalx">
            <div class="modalxa"></div>
        </div>
    </div>

    <footer class="lowin-footer">
        Design By sen --<a href="https://mail.qq.com/" target="_blank" title="xue.sen@qq.com">xue.sen@qq.com</a>.
    </footer>


</div>


<script type="text/javascript" th:src="@{/js/jquery-3.3.1.min.js}"></script>
<script type="text/javascript" th:src="@{/js/auth.js}"></script>
<script type="text/javascript" th:src="@{/js/jquery.cookie.js}"></script>
<script type="text/javascript" th:src="@{/js/jquery.base64.js}"></script>
<script type="text/javascript" th:src="@{/js/sweetalert-dev.js}"></script>
<script type="text/javascript" th:src="@{/js/mjs/mjs_login.js}"></script>
</body>

<script>
    function dologin() {
        var email = $("#email").val();
        var plainPassword = $("#plainPassword").val();
        var param = {"email":email,"plainPassword":plainPassword};
        $.post("/admin/doLogin",param,function (data) {
                if(data.state==200){
                    xtip.msg(data.message, {icon: 's'});
                    location.href="/admin/toMain";
                }
                else{
                    xtip.msg(data.message, {icon: 'e'});
                }
        })
    }


    $("#email1").blur(function () {
          var email1=$("#email1").val();
          $.post("/admin/checkEmail",{"email":email1},function (data) {
              if(data.state==200){
                  // alert(data.message);
                  xtip.msg(data.message, {icon: 's'});
              }
              else{
                  xtip.msg(data.message, {icon: 'e'});
              }
          });
    });

   $("#username").blur(function () {
        var username=$("#username").val();
        $.post("/admin/checkUsername",{"username":username},function (data) {
            if(data.state==200){
                // alert(data.message);
            }
            else{
                xtip.msg(data.message, {icon: 'e'});
            }
        });
    });



    $("#registerPassword").blur(function () {
        //获取输入密码
        var  plainPassword1= $("#registerPassword").val();
        if(plainPassword1==null||plainPassword1==""){
            xtip.msg('密码不能为空', {icon: 'e'});
            return;
        }
    });

    $("#code").blur(function () {
        //获取输入密码
        var  code= $("#code").val();
        if(code==null||code==""){
            xtip.msg('验证码不能为空', {icon: 'e'});
            return;
        }
    });
    /*发送邮件获取验证码*/
    $("#sendBtn").click(function () {
        var email1 = $("#email1").val();
        $.post("/admin/sendEmail", {"email": email1}, function (data) {
            xtip.msg(data.message, {icon: 's'});
        });
    });
    //给注册按钮添加点击事件  click()

    function register() {
        var username=$("#username").val();
        var email = $("#email1").val();
        var plainPassword = $("#registerPassword").val();
        var code=$("#code").val();
        var description=$("#description").val();
        var param = {"username":username,"email":email,"plainPassword":plainPassword,"code":code,"description":description};
        $.post("/admin/doRegister",param,function (data) {
            if(data.state==200){
                // alert(data.message);
                xtip.msg(data.message, {icon: 's'});
                location.href="/admin/login";
            }
            else{
                xtip.msg(data.message, {icon: 'e'});
            }
        });
    }



</script>
</html>